<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="ntModalLabel">{:lang("add/change_container")}</h4>
</div>
<form class="modal-body" id="formbox">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="alert alert-dismissable alert-info">
                <button type="button" class="close">×</button>
                <p></p>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#edit_base" data-toggle="tab">{:lang("basic_information")}</a>
                </li>
                <li>
                    <a href="#edit_more" data-toggle="tab">{:lang("feed_content")}</a>
                </li>
                <li>
                    <a href="#edit_info" data-toggle="tab">{:lang("container_information")}</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="row tab-content">
        <div class="col-md-12 tab-pane active" id="edit_base" >
            <table class="table table-hover ntTable">
                <tbody>
                <tr>
                    <td>{:lang('name')}<span class="required"></span></td>
                    <td><input type="text" class="form-control" name="name" value="{$data.info.name|default=''}"></td>
                    <td>{:lang("voyage")}</td>
                    <td>{:lang('CHINA')} >> {:lang('BRASIL')}</td>
                </tr>
                <tr>
                    <td>{:lang("preparation_date")}<span class="required"></span></td>
                    <td>
                        <div class="input-group date form_datetime" data-date-format="yyyy-mm-dd" data-link-field="ready_day">
                            <input class="form-control" type="text" name="ready_day" value="{$data.info.ready_day|default=''}">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar" style="margin:0"></span></span>
                        </div>
                        <input type="hidden" id="ready_day" value="" />
                    </td>
                    <td>{:lang("container_type")}</td>
                    <td>
                        <select class="form-control" name="type_id">
                            <option value="">{:lang('please_select')}</option>
                            {volist name="data.container_type" id="vo"}
                            {eq name="vo.id" value="$data.info.type_id|default=''"}
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            {else/}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/eq}
                            {/volist}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>{:lang("place_of_departure")}</td>
                    <td>
                        <select class="form-control" name="port_start">
                            <option value="">{:lang('please_select')}</option>
                            {volist name="data.port_start" id="vo"}
                            {eq name="vo.id" value="$data.info.port_start|default=''"}
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            {else/}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/eq}
                            {/volist}
                        </select>
                    </td>
                    <td>{:lang("goods_loan")}</td>
                    <td>
                        <select class="form-control" name="co_id_start">
                            <option value="">{:lang('please_select')}</option>
                            {volist name="data.co_id_start" id="vo"}
                            {eq name="vo.id" value="$data.info.co_id_start|default=''"}
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            {else/}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/eq}
                            {/volist}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>{:lang("destination")}</td>
                    <td>
                        <select class="form-control" name="port_arrival">
                            <option value="">{:lang('please_select')}</option>
                            {volist name="data.port_arrival" id="vo"}
                            {eq name="vo.id" value="$data.info.port_arrival|default=''"}
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            {else/}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/eq}
                            {/volist}
                        </select>
                    </td>
                    <td>{:lang("goods_loan")}</td>
                    <td>
                        <select class="form-control" name="co_id_arrival">
                            <option value="">{:lang('please_select')}</option>
                            {volist name="data.co_id_arrival" id="vo"}
                            {eq name="vo.id" value="$data.info.co_id_arrival|default=''"}
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            {else/}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/eq}
                            {/volist}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>{:lang('edit')}</td>
                    <td colspan="3"> {$data.info.update_name|default=''} / {$data.info.update_date|default=''} </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="col-md-12 tab-pane" id="edit_more" >
            <table class="table table-hover ntTable">
                <tbody>
                <tr>
                    <td>{:lang("carrier")}</td>
                    <td>
                        <select class="form-control" name="carrier_id">
                            <option value="">{:lang('please_select')}</option>
                            {volist name="data.carrier" id="vo"}
                            {eq name="vo.id" value="$data.info.carrier_id|default=''"}
                            <option value="{$vo.id}" selected>{$vo.content}</option>
                            {else/}
                            <option value="{$vo.id}">{$vo.content}</option>
                            {/eq}
                            {/volist}
                        </select>
                    </td>
                    <td>{:lang("booking_number")}</td>
                    <td><input type="text" name="so_no" value="{$data.info.so_no|default=''}" class="form-control" value=""></td>
                </tr>
                <tr>
                    <td>{:lang("container_number")}</td>
                    <td><input type="text" name="container_no" value="{$data.info.container_no|default=''}" class="form-control" value=""></td>
                    <td>{:lang("seal_number")}</td>
                    <td><input type="text" name="seal_no" value="{$data.info.seal_no|default=''}" class="form-control" value=""></td>
                </tr>
                <tr>
                    <td>{:lang("overweight")}</td>
                    <td><input type="text" name="weight" value="{$data.info.weight|default=''}" class="form-control" value=""></td>
                    <td>{:lang("bill_of_lading")}</td>
                    <td><input type="text" name="bl_no" value="{$data.info.bl_no|default=''}" class="form-control" value=""></td>
                </tr>
                <tr>
                    <td>{:lang("sailing_date")}</td>
                    <td>
                        <div class="input-group date form_datetime"  data-link-field="etd_day">
                            <input class="form-control" type="text" name="etd_day" value="{$data.info.etd_day|default=''}">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar" style="margin:0"></span></span>
                        </div>
                        <input type="hidden" id="etd_day" value="" />
                    </td>
                    <td>{:lang("date_of_arrival")}</td>
                    <td>
                        <div class="input-group date form_datetime" data-link-field="etd_day">
                            <input class="form-control" type="text" name="eta_day" value="{$data.info.eta_day|default=''}">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar" style="margin:0"></span></span>
                        </div>
                        <input type="hidden" id="etd_day" value="" />
                    </td>

                </tr>
                </tbody>
            </table>
            <input type="hidden" name="id" value="{$data.info.id|default=''}">
        </div>
        <div class="col-md-12 tab-pane" id="edit_info" >
            <table class="table table-hover ntTable">
                <tbody>
                <tr>
                    <td>{:lang("container_ID")}</td>
                    <td>{$data.info.id|default=''}</td>
                    <td>{:lang('status')}</td>
                    <td>{$data.info.status|default=''}</td>
                </tr>
                <tr>
                    <td>{:lang('name')}</td>
                    <td>{$data.info.name|default=''}</td>
                    <td>{:lang('serial_number')}</td>
                    <td>{$data.info.code|default=''}</td>
                </tr>
                <tr>
                    <td>{:lang("feed_content")}</td>
                    <td colspan="3">{:lang("bill_of_lading")}:{$data.info.bl_no|default=''} / {:lang("carrier")}：{$data.info.carrier_id_name|default=''} / {:lang("container_number")}：{$data.info.container_no|default=''} / {:lang("seal_number")}: {$data.info.seal_no|default=''} / 过磅重: {$data.info.weight|default=''} KGS / {:lang("box_quantity")}： {$data.info.sum_ctn|default=''} CTN </td>
                </tr>
                <tr>
                    <td>{:lang('total')}</td>
                    <td colspan="3">
                        {:lang("weight")}： {$data.info.sum_kgs|default=''} <span class="unit">KGS</span> /
                        {:lang("box_quantity")}： {$data.info.sum_ctn|default=''} <span class="unit">CTN</span> /
                        体积： {$data.info.sum_cbm|default=''} <span class="unit">CBM</span> /
                        {:lang("goods_value")}：{$data.info.sum_value|default=''} <span class="unit">CNY</span>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</form>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>{:lang('cancel')}</button>
    <button type="button" id="qudins" class="btn btn-primary" style="padding-left:24px;padding-right:24px"><span class="glyphicon glyphicon-floppy-disk"></span>{:lang('save')}</button>
</div>
<script>
    $(document).ready(function () {
        var lang = $('#lang').text();
        var language = '';
        if (lang == 'pt-br') {
            language = 'pt-BR';
            format = 'mm-dd-yyyy';
        } else if (lang == 'en-us') {
            language = 'en';
            format = 'mm-dd-yyyy';
        } else {
            language = 'zh-CN';
            format = 'yyyy-mm-dd'
        }
        //设置modal垂直居中,移动
        // modalSetting(".modal");
        // datatimepicker 设置
        $('.form_datetime').datetimepicker({
            language: language, // en ,zh-CN, pt-BR
            format: format,
            minView: 'month',
            weekStart: 0, //一周从哪一天开始
            todayBtn: 1, //底部会出现一个今天
            autoclose: true,//自动关闭
            todayHighlight: 1,//高亮今天日期
            startView: 2,//显示的视图
            forceParse: 0,//当选择器关闭的时候，是否强制解析输入框中的值
            showMeridian: 1
        });
    });
    //数据的提交
    $('#qudins').click(function () {
        subfn()
    })
    var addbm = true;
    function subfn() {
        if (addbm) {
            $.ajax({
                url: '/Admin/logistics/containeredit',
                type: 'post',
                data: $("#formbox").serialize(),
                dataType: 'json',
                success: function (res) {
                    if (res.status != 1) {
                        change_mes_type('.modal-body .alert',res.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+res.msg+'<br>')
                    } else {
                        change_mes_type('.alert',res.status)
                        addbm = false
                        $('.alert').show()
                        $('.alert p').html('*'+res.msg+'<br>')
                        $('#container_editModal').modal('hide')
                    }
                }
            });
        }
    }
    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            $('form').each(function () {
                event.preventDefault();
            });
            subfn()
        }
    });
</script>